// 网站信息表格


import React from 'react';
import {
    Card,
    Input,
    Divider
} from 'antd'
import {inject, observer} from "mobx-react";
import {Redirect} from 'react-router-dom'

const Search = Input.Search;


@inject('blogStore')
@observer
export default class SearchInput extends React.Component {

    constructor(props) {
        super(props);
        this.state = {redirect:false};
    }


    searchBlog = (searchKey) => {
        console.debug(`搜索=>${searchKey}`)
        this.props.blogStore.update(searchKey);
        this.setState({redirect:true})
    };

    render() {
        if (this.state.redirect) {
            return <Redirect push to="/"/>;
        }
        return (
            <div>
                <Card style={{width: 300}}>
                    <Divider>文章搜索</Divider>
                    <Search placeholder="你好,新世界！"
                            onSearch={value => this.searchBlog(value)}
                            enterButton/>
                </Card>
            </div>

        );
    }

}